package com.anan.ehcache.service;

import net.sf.ehcache.Cache;
import net.sf.ehcache.CacheManager;
import net.sf.ehcache.Element;

import javax.xml.transform.Source;

/**
 * @code @Author:Painter
 * @code @project_name:ehcache
 * @code @class_name:CacheTest
 * @code @system_login_name:23287
 * @code @time: 2023/5/30  15:10
 */


public class CacheTest {

    public static void main(String[] args) {
        CacheManager cacheManager = CacheManager.create();   // 创建cache管理器
        Cache anan = cacheManager.getCache("anan");  //   获取指定的缓存
        anan.put(new Element("key1", "value1"));   //  添加元素
        Element key1 = anan.get("key1");  // 获取元素
        String objectValue = (String) key1.getObjectValue();   // 获取元素对象
        System.out.println(objectValue);

    }
}
